home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 11, No. 10 (1990-10)(MindCraft Publishing)(Side A)[a].zip
/
Nibble Volume 11, No. 10 (1990-10)(MindCraft Publishing)(Side A)[a].po
/
TE.ASM.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
20KB
|
562 lines
****************************************
* *
* TE.ASM Source Listing (Data Fork) *
* by Sandy Mossberg *
* *
* APW Assembler/Linker *
* Requires APW Tools and Interfaces, *
* version 1.1 *
* *
* Copyright (C) 1990 *
* by MindCraft Publ. Corp. *
* Concord, MA 01742 *
* *
****************************************
mcopy te.mac
keep te.dfork
ScreenMode gequ $80 ;640x200 super hi-res mode
*****************************************************************
*
MainLoop start
*
* Main program loop:
*
*****************************************************************
using GlobalData
phk ;equate program bank
plb ; with data bank
jsr StartUp ;startup tool sets
jsr InitDesktop ;initialize desktop
jsr InitApplic ;initialize application
jsr EventLoop ;scan for events
jsr ShutApplic ;free program memory
jsr ShutDown ;shutdown tool sets
Quit _QuitGS QuitParm ;quit to calling application
;................................................................
;
; MainLoop data:
;
QuitParm anop ;Quit parmlist (GS/OS class 1)
dc i2'0' ;pCount = 0 (input)
end
*****************************************************************
*
StartUp start
*
* Startup tool sets:
*
*****************************************************************
using GlobalData
; Startup first 2 tool sets:
_TLStartUp ;----start Tool Locator
pha ;space for result
_MMStartUp ;----start Memory Manager
jsr FatalErr
PullWord MasterID ;save master ID
; Startup other tool sets:
PushLong #0 ;space for result
PushWord MasterID ;master ID
PushWord #2 ;ref is resource
PushLong #$07FE0001 ;ref to orig StartStop record
_StartUpTools ;----call StartUpTools
jsr FatalErr
PullLong SSRecFinal ;ref to final StartStop record
_InitCursor ;convert cursor: wait -> arrow
rts
end
*****************************************************************
*
ShutDown start
*
* Shutdown tools sets:
*
*****************************************************************
using GlobalData
PushWord #1 ;reference is handle
PushLong SSRecFinal ;ref to final StartStop record
_ShutDownTools ;----call ShutDownTools
PushWord MasterID ;master ID
_MMShutDown
_TLShutDown
rts
end
*****************************************************************
*
FatalErr start
*
* Check for error and handle fatal error:
*
*****************************************************************
bcs FE01 ;error detected
rts ;no error on carry clear
FE01 pha ;error code in A reg
PushLong #0 ;use default failure message
_SysFailMgr ;die a horrible death
end
*****************************************************************
*
InitDesktop start
*
* Initialize desktop:
*
*****************************************************************
PushLong #0 ;space for result
PushWord #2 ;reference is resource
PushLong #1 ;reference to menu bar
PushLong #0 ;system menu bar
_NewMenuBar2 ;create menu bar
_SetSysBar ;set system bar (handle on stack)
PushLong #0 ;use system menu bar
_SetMenuBar ;set current menu bar
PushLong #0 ;entire desktop
_RefreshDesktop ;refresh desktop
PushWord #1 ;ID of NDA menu
_FixAppleMenu ;setup NDA menu
pha ;space for result
_FixMenuBar ;set standard size of menu bar
pla ;discard menu height
_DrawMenuBar ;display current menu bar
rts
end
*****************************************************************
*
InitApplic start
*
* Initialize application specific data:
*
*****************************************************************
using GlobalData
stz QuitFlag ;clear quit flag
stz WindFlag ;clear window flag
rts
end
*****************************************************************
*
EventLoop start
*
* Handle events:
*
*****************************************************************
using GlobalData
jsr ChangeMenus ;dim/undim menu title/items
anop ;scan events with TaskMaster
pha ;space for result
PushWord #$FFFF ;handle all events
PushLong #TaskRecord ;ptr to extended task record
_TaskMaster ;get the event
pla ;get result
anop ;handle event
asl a ;create index into 2-byte
tax ; entries of task table
jsr (TaskTable,x) ;call event handler
anop ;check for quit signal
lda QuitFlag
bpl EventLoop ;Quit not chosen
rts
;................................................................
;
; EventLoop data:
;
TaskTable anop ;GetNextEvent event handlers:
dc i2'DoRTS' ; 0 = nullEvt
dc i2'DoRTS' ; 1 = mouseDownEvt
dc i2'DoRTS' ; 2 = mouseUpEvt
dc i2'DoRTS' ; 3 = keyDownEvt
dc i2'DoRTS' ; 4 = undefined
dc i2'DoRTS' ; 5 = autoKeyEvt
dc i2'DoRTS' ; 6 = updateEvt
dc i2'DoRTS' ; 7 = undefined
dc i2'DoRTS' ; 8 = activateEvt
dc i2'DoRTS' ; 9 = switchEvt
dc i2'DoRTS' ;10 = deskAccEvt
dc i2'DoRTS' ;11 = driverEvt
dc i2'DoRTS' ;12 = app1Evt
dc i2'DoRTS' ;13 = app2Evt
dc i2'DoRTS' ;14 = app3Evt
dc i2'DoRTS' ;15 = app4Evt
anop ;TaskMaster event handlers:
dc i2'DoRTS' ;16 = wInDesktop
dc i2'DoMenu' ;17 = wInMenuBar
dc i2'DoRTS' ;18 = wClickCalled
dc i2'DoRTS' ;19 = wInContent
dc i2'DoRTS' ;20 = wInDrag
dc i2'DoRTS' ;21 = wInGrow
dc i2'DoClose' ;22 = wInGoAway
dc i2'DoRTS' ;23 = wInZoom
dc i2'DoRTS' ;24 = wInInfo
dc i2'DoMenu' ;25 = wInSpecial
dc i2'DoRTS' ;26 = wInDeskItem
dc i2'DoRTS' ;27 = wInFrame
dc i2'DoRTS' ;28 = wInactMenu
dc i2'DoRTS' ;29 = wClosedNDA
dc i2'DoRTS' ;30 = wCalledSysEdit
dc i2'DoRTS' ;31 = wTrackZoom
dc i2'DoRTS' ;32 = wHitFrame
dc i2'DoRTS' ;33 = wInControl
dc i2'DoRTS' ;34 = wInControlMenu
end
*****************************************************************
*
DoMenu start
*
* Handle menu events (menu items must be numbered sequentially):
*
*****************************************************************
using GlobalData
sec
lda TaskData ;get menu item ID
sbc #250 ;convert N250 into 0th item
asl a ;create index into 2-byte
tax ; entries of menu item table
jsr (ItemTable,x) ;call menu item handler
PushWord #0 ;TRUE=hilite, FALSE=unhilite
PushWord TaskData+2 ;menu ID
_HiliteMenu ;unhighlight menu
rts
;................................................................
;
; DoMenu data:
;
ItemTable anop ;menu item handlers
dc i2'DoRTS' ;250 = Undo
dc i2'DoRTS' ;251 = Cut
dc i2'DoRTS' ;252 = Copy
dc i2'DoRTS' ;253 = Paste
dc i2'DoRTS' ;254 = Clear
dc i2'DoClose' ;255 = Close
dc i2'DoAbout' ;256 = About...
dc i2'DoQuit' ;257 = Quit
dc i2'DoNew' ;258 = New
dc i2'DoOpen' ;259 = Open
dc i2'DoRTS' ;260 = Save...
dc i2'DoRTS' ;261 = Page Setup...
dc i2'DoRTS' ;262 = Print...
end
*****************************************************************
*
ShutApplic start
*
* Deallocate memory before shutting down tool sets:
*
*****************************************************************
using GlobalData
rts
end
*****************************************************************
*
DoRTS start
*
* Ignore an event:
*
*****************************************************************
rts
end
*****************************************************************
*
DoQuit start
*
* Turn on quit flag to terminate this application:
*
*****************************************************************
using GlobalData
lda #$8000
sta QuitFlag ;set quit flag
rts
end
*****************************************************************
*
DoClose start
*
* Close front window:
*
*****************************************************************
using GlobalData
PushLong #0 ;space for result
_FrontWindow ;get ptr to front window
PullLong FrontWinPtr ;save ptr
lda FrontWinPtr ;check for open window
ora FrontWinPtr+2
beq Done ;no window open
PushLong FrontWinPtr ;ptr to front window
_CloseNDAbyWinPtr ;close NDA window
bcc Done ;NDA window closed
anop ;application window in front
PushLong #0 ;get menu item ID in wRefCon
PushLong FrontWinPtr
_GetWRefCon
plx ;ID in lo
pla ;discard hi
phx ;enable menu item
_EnableMItem
PushLong FrontWinPtr ;ptr to front window
_CloseWindow ;close application window
Done rts
end
*****************************************************************
*
DoAbout start
*
* Handle About item in Apple menu (display title and credits):
*
*****************************************************************
pha ;space for result
PushWord #5 ;ref is resource, P-string
PushLong #0 ;no substitution array
PushLong #$07FE0001 ;reference to alert string
_AlertWindow ;display alert window
pla ;discard button ID (OK)
rts
end
*****************************************************************
*
DoNew start
*
* Open new TextEdit window:
*
*****************************************************************
using GlobalData
PushLong #0 ;space for result
PushLong #0 ;ptr to replacement title
PushLong TaskData ;repl refCon (New item ID)
PushLong #DrawNew ;ptr to repl content drawing
PushLong #0 ;ptr to repl window defProc
PushWord #2 ;ref is resource
PushLong #$1001 ;ref to window template
PushWord #$800E ;type 1 (stnd) window template
_NewWindow2
jsr LocalError ;check nonfatal error
PullLong NewWindPtr ;ptr to window GrafPort
bcs Done ;error
PushWord TaskData ;dim New item in File menu
_DisableMItem
Done rts
end
*****************************************************************
*
DoOpen start
*
* Open preset TextEdit window:
*
*****************************************************************
using GlobalData
PushLong #0 ;space for result
PushLong #0 ;ptr to replacement title
PushLong TaskData ;repl refCon (Open item ID)
PushLong #DrawOpen ;ptr to repl content drawing
PushLong #0 ;ptr to repl window defProc
PushWord #2 ;ref is resource
PushLong #$1101 ;ref to window template
PushWord #$800E ;type 1 (stnd) window template
_NewWindow2
jsr LocalError ;check nonfatal error
PullLong OpenWindPtr ;ptr to window GrafPort
bcs Done ;error
PushWord TaskData ;dim New item in File menu
_DisableMItem
Done rts
end
*****************************************************************
*
DrawNew start
*
* Draw content region of New window (called by TaskMaster):
*
*****************************************************************
using GlobalData
PushLong NewWindPtr ;ptr to New window
_DrawControls
rtl
end
*****************************************************************
*
DrawOpen start
*
* Draw content region of Open window (called by TaskMaster):
*
*****************************************************************
using GlobalData
PushLong OpenWindPtr ;ptr to New window
_DrawControls
rtl
end
*****************************************************************
*
ChangeMenus start
*
* Enable or disable menu titles and items during null events:
*
*****************************************************************
using GlobalData
PushLong #0 ;space for result
_FrontWindow ;get ptr to front window
PullLong FrontWinPtr ;save ptr
ldx #$8000 ;assume open window
lda FrontWinPtr ;check for open window
ora FrontWinPtr+2
bne CheckFlag ;open window found
ldx #0 ;no open window
CheckFlag cpx WindFlag
bne ChangeFlag ;flag changed
rts ;flag unchanged so exit
ChangeFlag stx WindFlag ;set new flag
lda WindFlag ;check for open window
bpl NoWind ;no window open
anop ;window open so enable specials
PushWord #250 ;Undo
_EnableMItem
PushWord #251 ;Cut
_EnableMItem
PushWord #252 ;Copy
_EnableMItem
PushWord #253 ;Paste
_EnableMItem
PushWord #254 ;Clear
_EnableMItem
PushWord #255 ;Close
_EnableMItem
PushWord #$FF7F ;flags: enable menu
PushWord #3 ;Edit menu number
_SetMenuFlag ;enable Edit menu title
bra Done
NoWind anop ;no window open so dim specials
PushWord #255 ;Close
_DisableMItem
PushWord #$80 ;flags: diaable menu
PushWord #3 ;Edit menu number
_SetMenuFlag ;dim Edit menu title and items
Done _DrawMenuBar ;display current menu bar
rts
end
****************************************************************
*
LocalError start
*
* Handle nonfatal errors: entry A = error code
*
****************************************************************
using GlobalData
bcc Done ;no error
tax ;save error code
pha ;space for result
PushWord #0 ;type of substitution string
PushLong #0 ;ptr to substitution string
phx ;error code
_ErrorWindow ;display error window
pla ;discard button number
sec ;return with error signal
Done rts
end
*****************************************************************
*
GlobalData data
*
* Global program data:
*
*****************************************************************
MasterID ds 2 ;our master memory ID
SSRecFinal ds 4 ;ptr to final StartStop record
FrontWinPtr ds 4 ;ptr to front window in Close item
NewWindPtr ds 4 ;ptr to New window GrafPort
OpenWindPtr ds 4 ;ptr to Open window GrafPort
QuitFlag ds 2 ;quit=MI, no quit=PL
WindFlag ds 2 ;open window=MI, no window=PL
TaskRecord anop ;new extended task record
What ds 2 ;event code
Message ds 4 ;event message
When ds 4 ;ticks since startup
Where ds 4 ;global position of mouse
Modifiers ds 2 ;state of modifier keys
TaskData ds 4 ;extended event data
TaskMask dc i4'$1FFFFF' ;bit flag (handle all events)
LastClkTick ds 4 ;tick value at last click
ClickCount ds 2 ;type of last click
TaskData2 ds 4 ;additional data
TaskData3 ds 4 ;additional data
TaskData4 ds 4 ;additional data
LastClickY ds 2 ;vertical axis of last click
LastClickX ds 2 ;horizontal axis of last click
end